<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:10pt; font-weight:400; font-style:normal;">
<p style=" margin-top:18px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a name="question-header"></a><a href="https://ru.stackoverflow.com/questions/1005694/%d0%be%d1%88%d0%b8%d0%b1%d0%ba%d0%b8-ssl-%d0%bf%d1%80%d0%be%d1%82%d0%be%d0%ba%d0%be%d0%bb%d0%b0"><span style=" font-size:xx-large; font-weight:600; text-decoration: underline; color:#0000ff;">о</span></a><span style=" font-size:xx-large; font-weight:600; text-decoration: underline; color:#0000ff;">шибки SSL протокола</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="https://ru.stackoverflow.com/questions/ask"><span style=" text-decoration: underline; color:#0000ff;">Задать вопрос</span></a></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Вопрос задан 4 года 7 месяцев назад</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Изменён <a href="https://ru.stackoverflow.com/questions/1005694/%D0%BE%D1%88%D0%B8%D0%B1%D0%BA%D0%B8-ssl-%D0%BF%D1%80%D0%BE%D1%82%D0%BE%D0%BA%D0%BE%D0%BB%D0%B0?lastactivity"><span style=" text-decoration: underline; color:#0000ff;">3 года 8 месяцев назад</span></a></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Просмотрен 4k раз</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a name="mainbar"></a>7</p>
<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">когда использую самый обыкновенный <span style=" font-family:'Courier New';">requests.get()</span> питон выдает ошибки ssl сертификата</p>
<p style=" margin-top:12px; margin-bottom:12px; margin-left:40px; margin-right:40px; -qt-block-indent:0; text-indent:0px;">Traceback (most recent call last): File &quot;C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py&quot;, line 603, in urlopen chunked=chunked) File &quot;C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py&quot;, line 344, in _make_request self._validate_conn(conn) File &quot;C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py&quot;, line 843, in _validate_conn conn.connect() File &quot;C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connection.py&quot;, line 370, in connect ssl_context=context) File &quot;C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\util\ssl_.py&quot;, line 355, in ssl_wrap_socket return context.wrap_socket(sock, server_hostname=server_hostname) File &quot;C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\lib\ssl.py&quot;, line 412, in wrap_socket session=session File &quot;C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\lib\ssl.py&quot;, line 853, in _create self.do_handshake() File &quot;C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\lib\ssl.py&quot;, line 1117, in do_handshake self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)</p>
<p style=" margin-top:12px; margin-bottom:12px; margin-left:40px; margin-right:40px; -qt-block-indent:0; text-indent:0px;">During handling of the above exception, another exception occurred:</p>
<p style=" margin-top:12px; margin-bottom:12px; margin-left:40px; margin-right:40px; -qt-block-indent:0; text-indent:0px;">Traceback (most recent call last): File &quot;C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\adapters.py&quot;, line 449, in send timeout=timeout File &quot;C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py&quot;, line 641, in urlopen _stacktrace=sys.exc_info()[2]) File &quot;C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\util\retry.py&quot;, line 399, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='e.mail.ru', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)')))</p>
<p style=" margin-top:12px; margin-bottom:12px; margin-left:40px; margin-right:40px; -qt-block-indent:0; text-indent:0px;">During handling of the above exception, another exception occurred:</p>
<p style=" margin-top:12px; margin-bottom:12px; margin-left:40px; margin-right:40px; -qt-block-indent:0; text-indent:0px;">Traceback (most recent call last): File &quot;C:\Users\ADMIN\Desktop\test1.py&quot;, line 3, in requests.get(&quot;<a href="https://e.mail.ru/"><span style=" text-decoration: underline; color:#0000ff;">https://e.mail.ru</span></a>&quot;) File &quot;C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\api.py&quot;, line 75, in get return request('get', url, params=params, **kwargs) File &quot;C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\api.py&quot;, line 60, in request return session.request(method=method, url=url, **kwargs) File &quot;C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\sessions.py&quot;, line 533, in request resp = self.send(prep, **send_kwargs) File &quot;C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\sessions.py&quot;, line 646, in send r = adapter.send(request, **kwargs) File &quot;C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\adapters.py&quot;, line 514, in send raise SSLError(e, request=request) requests.exceptions.SSLError: HTTPSConnectionPool(host='e.mail.ru', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)')))</p>
<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Попробовал воспользоваться пипом, после чего вылетела вот такая ошибка</p>
<p style=" margin-top:12px; margin-bottom:12px; margin-left:40px; margin-right:40px; -qt-block-indent:0; text-indent:0px;">C:\Users\ADMIN&gt;cd AppData\Local\Programs\Python\Python37\scripts</p>
<p style=" margin-top:12px; margin-bottom:12px; margin-left:40px; margin-right:40px; -qt-block-indent:0; text-indent:0px;">C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\Scripts&gt;pip install ssl Collecting ssl Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFI CATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certif icate (_ssl.c:1056)'))': /simple/ssl/ Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFI CATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certif icate (_ssl.c:1056)'))': /simple/ssl/<br />Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFI CATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certif icate (_ssl.c:1056)'))': /simple/ssl/ Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFI CATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certif icate (_ssl.c:1056)'))': /simple/ssl/<br />Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFI CATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certif icate (_ssl.c:1056)'))': /simple/ssl/ Could not fetch URL <a href="https://pypi.org/simple/ssl/"><span style=" text-decoration: underline; color:#0000ff;">https://pypi.org/simple/ssl/</span></a>: There was a problem confirmi ng the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retr ies exceeded with url: /simple/ssl/ (Caused by SSLError(SSLCertVerificationError (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get l ocal issuer certificate (_ssl.c:1056)'))) - skipping Could not find a version that satisfies the requirement ssl (from versions: ) No matching distribution found for ssl You are using pip version 19.0.3, however version 19.2 is available. You should consider upgrading via the 'python -m pip install --upgrade pip' command.</p>
<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">так же пробовал добавить сайты в исключения командой</p>
<p style=" margin-top:12px; margin-bottom:12px; margin-left:40px; margin-right:40px; -qt-block-indent:0; text-indent:0px;">pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org pip setuptools</p>
<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">однако это тоже не принесло никаких результатов, ошибка все та же</p>
<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Искал решение проблемы, но все они для макоси, в то время как у меня это все происходит на винде. Питон версии 3.7.3</p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p>
<p style=" margin-top:16px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a name="answers"></a><span style=" font-size:x-large; font-weight:600;">1</span><span style=" font-size:x-large; font-weight:600;"> ответ</span></p>
<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">На вашем ПК проблема с цепочкой корневых сертификатов. В качестве временного костыля, можете убрать проверку валидности сертификата, добавив в код:</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas';">import ssl</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas'; background-color:#eff0f1;">ssl._create_default_https_context = ssl._create_unverified_context</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><br /></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">или в самом реквесте указать verify = False:</p>
<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-weight:600; color:#55aa00;">requests.get(url, verify=False)</span></p>
<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Если устранять проблему правильно, то нужно либо обновить сертификаты, путь до их располжения можно узнать через</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas';">import ssl</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><span style=" font-family:'Consolas';">print(ssl.get_default_verify_paths().openssl_cafile) </span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eff0f1;"><br /></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10px;"><br /></p>
<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">либо использовать серты, которые идут в составе либ, например certifi.</p></body></html>